#include<bits/stdc++.h>
#define ONLINE_JUDGE
#define ll long long
#define ull unsigned long long
using namespace std;

const ll N = 4e6 + 10, INF = 0x3f3f3f3f;

ll n, d;
ll x[N], y[N];
ll mpx[N], mpy[N];
ll cnt[N];

void solve()
{
    cin >> n >> d;
    for (ll i = 1;i <= n;i++) {
        cin >> x[i] >> y[i];
        x[i] += 2e6;y[i] += 2e6;
        mpx[x[i]]++;
        mpy[y[i]]++;
    }
    ll l = 0, r = n, sum = 0;
    for (ll i = 1;i <= n;i++) sum += y[i];
    for (ll i = 0;i <= 4e6;i++) {
        if (sum <= d) cnt[sum]++;//统计y坐标上距离为sum的坐标位置个数
        l += mpy[i];r -= mpy[i];
        sum = sum + l - r;
    }
    for (ll i = 1;i <= 1e6;i++) cnt[i] += cnt[i - 1];//统计距离小于i的个数前缀和

    l = 0, r = n, sum = 0;
    ll ans = 0;
    for (ll i = 1;i <= n;i++) sum += x[i];
    for (ll i = 0;i <= 4e6;i++) {
        if (sum <= d) ans += cnt[d - sum];//快速查询小于d - sum的y坐标位置
        l += mpx[i];r -= mpx[i];
        sum = sum + l - r;
    }
    // for (int i = 0;i <= 10;i++) cout << cnt[i] << ' ';
    cout << ans;
}

signed main()
{
    // ios::sync_with_stdio(0);
    // cin.tie(0);cout.tie(0);
#ifndef ONLINE_JUDGE
    std::istringstream in(R"()");
    std::cin.rdbuf(in.rdbuf());
#endif
    ll T = 1;
    //cin>>T;
    for (ll i = 1;i <= T;i++) {
        solve();
    }
}